<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    let Person = class {
        //构造方法，名称固定
        constructor(name = "Fu", age) {
            if (new.target === Person){
                throw new Error("Person是一个抽象类，不可以创建对象");
            }
            this.name = name;
            this._age = age;
            this.hubby = ["java", "c++"];
        }

        sayHello() {
            console.log("hello" + this.name);
        }

        //定义静态方法
        static t1() {
            //静态方法的this指向函数对象本身
            console.log("这是一个静态方法" + this.name + this._age);
        }
    }

    let p1 = new Person();
    console.log(p1);

    class Fu {
        constructor() {
            console.log("Fu");
        }
    }

    class Student extends Person/*, Fu*/ {
        constructor(name, age, score) {
            super(name, age);//调用父类中的构造方法
            // console.log(this.name);
            this.score = score;
        }

        study() {
            super.sayHello();
            this.sayHello();
            console.log(super.name);
            console.log(this.name + "经过了努力学习，高分是" + this.score);
        }
    }

    let s1 = new Student("s1", 18, 650);
    console.log(s1);
    // s1.sayHello();
    // Student.t1();
    s1.study();
</script>
</body>
</html>